
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE [dbo].gspSiteEvent_SEARCH
(
@eventId int = null,
@title nvarchar(150) = null,
@eventPlace nvarchar(300) = null,
@eventContent nvarchar(MAX) = null,
@eventTypeCode int = null,
@membersCount int = null,
@startDate datetime = null,
@finishDate datetime = null,
@isDeleted bit = null,
@isVisible bit = null,
@createDate datetime = null,
@lastModifiedDate datetime = null
)
AS

SELECT
  *
FROM
  [dbo].[SiteEvent]
WHERE
  (@eventId IS NULL OR [EventId] = @eventId)
AND
  (@title IS NULL OR @title = '' OR [Title] LIKE @title + '%')
AND
  (@eventPlace IS NULL OR @eventPlace = '' OR [EventPlace] LIKE @eventPlace + '%')
AND
  (@eventTypeCode IS NULL OR [EventTypeCode] = @eventTypeCode)
AND
  (@membersCount IS NULL OR [MembersCount] = @membersCount)
AND
  (@startDate IS NULL OR [StartDate] = @startDate)
AND
  (@finishDate IS NULL OR [FinishDate] = @finishDate)
AND
  (@isDeleted IS NULL OR [IsDeleted] = @isDeleted)
AND
  (@isVisible IS NULL OR [IsVisible] = @isVisible)
AND
  (@createDate IS NULL OR [CreateDate] = @createDate)
AND
  (@lastModifiedDate IS NULL OR [LastModifiedDate] = @lastModifiedDate)

GO
